﻿@using System.Web.Optimization
@using StackExchange.Opserver.Models
@using StackExchange.Opserver.Views.Shared
@{
    var topNodes = ViewData[ViewDataKeys.TopBoxOptions] as TopBoxOptions;
}
<!DOCTYPE html>
<html>
<head>
    <title>@Html.Raw((string)ViewData[ViewDataKeys.PageTitle])</title>
    <meta name="viewport" content="width=device-width">
    <link href="@Url.CacheBreaker("/Content/Styles.css")" rel="stylesheet" type="text/css" />
    <link href="@Url.CacheBreaker("/Content/img/apple-touch-icon.png")" rel="apple-touch-icon" />
    <script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
    @Scripts.Render("~/scripts/plugins.js")    @Scripts.Render("~/scripts/scripts.js")    <script>
        $(function() {
            Status.init({ SiteName: '@SiteSettings.SiteName', Tab:'@TopTabs.CurrentTab', HeaderRefresh: 10 });
            @if (topNodes != null && topNodes.AllNodes != null && topNodes.AllNodes.Any())
            {
                var serverJson = topNodes.AllNodes.Select(n => new
                    {
                        name = n.DisplayName,
                        node = n.Name,
                        sClass = n.MonitorStatus.Class(),
                        category = n.CategoryName
                    }).OrderBy(n => n.category).ThenBy(n => n.node);
                @:Status.NodeSearch.init({ nodes: @Json.Encode(serverJson).AsHtml() });
            }
        });
    </script>    @RenderSection("head", false)    @StackExchange.Profiling.MiniProfiler.RenderIncludes()
</head>
    <body class="@(Current.IsMobile ? "mobile" : "")">
        <div class="top-bar">
            @Html.Partial("~/Views/Shared/TopTabs.cshtml")
            <a href="/hub" class="logo"></a>
            <div class="top-nodes">
                @if (topNodes != null)
                {
                    if (topNodes.SearchOnly)
                    {
                        <div class="ddl">
                            <form action="@topNodes.Url" method="GET">
                                <input type="text" class="node-ddl search-ddl" placeholder="Search@(topNodes.SearchText.HasValue() ? " " + topNodes.SearchText : "")..." value="@topNodes.SearchValue" name="q" />
                                @if (topNodes.SearchParams != null)
                                {
                                    foreach (var p in topNodes.SearchParams)
                                    {
                                        <input type="hidden" name="@p.Key" value="@p.Value" />
                                    }
                                }
                            </form>
                        </div>
                    }
                    else
                    {
                        var s = topNodes.CurrentNode;
                        if (topNodes.AllNodes != null && topNodes.AllNodes.Any())
                        {
                        <div class="ddl">
                            <form action="@topNodes.Url" method="GET">
                                <input type="text" class="node-ddl@(s != null ? " left-icon " + s.MonitorStatus.Class() : "")" placeholder="Search@(topNodes.SearchText.HasValue() ? " " + topNodes.SearchText : "")..." value="@(s != null ? s.DisplayName : "")" name="node" />
                            </form>
                        </div>
                        }
                    }
                    @Html.Partial("IssuesList")
                }
            </div>
        </div>
        <div id="content">
            @RenderBody()
        </div>
    </body>
</html>